package com.zht.aspect;

import com.zht.entity.UserEntity;
import com.zht.service.SendMessageService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 切面新增用户数据
 *
 * @author zhaoht
 * @date 2024/6/6
 */
@Aspect
@Component
@Slf4j
public class AddUserAspect {

    @Autowired
    private SendMessageService sendMessageService;


    @Pointcut(value = "@annotation(com.zht.annotation.AddUserAnnotation)")
    public void pointCut(){}

    @AfterReturning(value = "pointCut()",returning = "out")
    public void afterReturn(UserEntity out){
        //接收返回对象新增数据库
        sendMessageService.addUser(out);
    }

}
